/*
 * ReceiveThread.hpp
 *
 *  Created on: Nov 15, 2014
 *      Author: toti
 */

#ifndef RECEIVETHREAD_HPP_
#define RECEIVETHREAD_HPP_

#include <pthread.h>
#include <semaphore.h>
#include <string>

#include <fstream>

#include <Misc/Config.hpp>
#include <Connectivity/TCPConnection.hpp>


class IReceiveCallback{

public:

	virtual ~IReceiveCallback(){}

	virtual void receiveCallback(std:: string& data) = 0;

};

class ReceiveThread{

private:

	pthread_t thread;

	TCPConnection *tcpConnection;

	std::ofstream *ofs;

	static void *startThread(void* object);


public:

	ReceiveThread(TCPConnection *tcpConnection);

	void registerReceiveCallback(IReceiveCallback *receiveCallback);

	void run();

};



#endif /* RECEIVETHREAD_HPP_ */
